export default {
  namespaced: true, // 为当前模块开启独立的 命名空间
  state: {
    name: "cart模块的数据",
    userInfo: {
      name: "张三",
      age: 18,
    },
  },
  getters: {},
  mutations: {
    changeName(state, msg) {
      console.log(msg);
      state.name = "aaa+++" + msg;
    },
    changeUserInfo(state, payload) {
      // state.userInfo = payload;
      state.userInfo.name = payload.name;
      state.userInfo.age = payload.age;
      console.log(payload);
    },
  },
  actions: {
    actChangeName(context, payload) {
      console.log(payload);
      // console.log(context);
      console.log("actChangeNameaction触发了");
      context.commit("changeName", msg);
    },
  },
  getters: {
    filters(state, getters, rootState) {
      console.log(getters); // 代表的是getters属性
      // rootState ---> 根节点的状态（也就是最外层的state）
      return state.name;
    },
  },
};
